﻿using Lidgren.Network;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Paintball.Network
{
    public abstract class ServerAgent : NetworkAgent
    {
        //Fields
        public NetServer Server
        {
            get
            {
                return Peer<NetServer>();
            }
        }

        //Construct
        public ServerAgent()
            : base(NetworkAgentMode.Server)
        {

        }
        
        //Methods
        protected void DefaultDiscoveryRequestHandler(NetIncomingMessage inc)
        {
            //We received a message from a client to discover us
            NetOutgoingMessage response = Server.CreateMessage();
            response.Write(string.Format("Server:{0}", ApplicationInstanceName));
            Server.SendDiscoveryResponse(response, inc.SenderEndPoint);
        }
    }
}
